/*
 * rentalTab.java
 *
 * Created on 12 novembre 2008, 10:17
 */

package GUI;

import java.awt.event.KeyEvent;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import kernel.Rental;

/**
 *
 * @author  coco
 */
public class rentalTab extends javax.swing.JPanel {

    /** Creates new form rentalTab */
    public rentalTab(){
        dc.setMinimumFractionDigits(2); 
        dc.setMaximumFractionDigits(2);
        

        String today = formatter.format(pickupDate);
        try {
            pickupDate = formatter.parse(today);
        } catch (ParseException ex) {
            Logger.getLogger(rentalTab.class.getName()).log(Level.SEVERE, null, ex);
        }
        returnDate = new Date(pickupDate.getTime()+((1000*24*60*60)));
        
        System.out.println(pickupDate.toString());
        System.out.println(returnDate.toString());
        initComponents();
    }

    
    public static void updateCustomer(){
        
       
        
        rentalCustomerIdInfo.setText(Integer.toString(GraphicalUserInterface.selectedCustomer.getID()));
        rentalCustomerAnredeInfo.setText(GraphicalUserInterface.selectedCustomer.getAnrede());
        rentalCustomerFirstNameInfo.setText(GraphicalUserInterface.selectedCustomer.getVorname());
        rentalCustomerSurnameInfo.setText(GraphicalUserInterface.selectedCustomer.getName());
        rentalCustomerCompanyInfo.setText(GraphicalUserInterface.selectedCustomer.getFirmennamen());
        rentalCustomerAddressInfo.setText(GraphicalUserInterface.selectedCustomer.getAdresse());
        rentalCustomerLicenseDateInfo.setText(GraphicalUserInterface.selectedCustomer.getFuehrerscheindatum());
        rentalCustomerLicenseClassInfo.setText(GraphicalUserInterface.selectedCustomer.getFuehrerscheinklassen());
        rentalCustomerDiscountInfo.setText(Float.toString(GraphicalUserInterface.selectedCustomer.getRebatt()));
        rentalCustomerPhoneInfo.setText(GraphicalUserInterface.selectedCustomer.getTelefonnummer());
        rentalCustomerBirthdayInfo.setText(GraphicalUserInterface.selectedCustomer.getGeburtsdatum());                
    }
    
    
    public static double calcPrice(float carFactor, float customerFactor,int totalDays ){
        float price;
        double daysFactor;
        int grund = 20;
        
        if(totalDays<10){
            daysFactor = ((-0.05) * totalDays + 1);
        }else daysFactor =  0.5;
        
        
        price = (float) (grund * carFactor * customerFactor * daysFactor) * totalDays;
        
        return price;
    }
    
        public static void updateCar(){
                       
		double result = 0;
                totalPrice = 0;
		long diff = returnDate.getTime() - pickupDate.getTime();
		double days =  ((diff / 1000) / 60 / 60 / 24);
                if(days<1) days =1;
            
            String[] selectedCarsTableColums = new String [] {
                    "ID", "Klasse", "Hersteller", "Modell", "Kennzeichen", "Sitzplätze", "Kilometerstand", "Erstzulassung", "Kraftstofftyp", "Preisfaktor", "Freikilometer", "Preis",
                };

            String[][] selectedCarsTableData = new String [GraphicalUserInterface.selectedCar.size()][12];

            for(int i=0; i<GraphicalUserInterface.selectedCar.size(); i++){
                selectedCarsTableData[i][0] = Integer.toString(GraphicalUserInterface.selectedCar.get(i).getID());
                selectedCarsTableData[i][1] = GraphicalUserInterface.selectedCar.get(i).getFahrzeugklasse();
                selectedCarsTableData[i][2] = GraphicalUserInterface.selectedCar.get(i).getHersteller();
                selectedCarsTableData[i][3] = GraphicalUserInterface.selectedCar.get(i).getModell();
                selectedCarsTableData[i][4] = GraphicalUserInterface.selectedCar.get(i).getKennzeichen();
                selectedCarsTableData[i][5] = Integer.toString(GraphicalUserInterface.selectedCar.get(i).getSitzplatze());
                selectedCarsTableData[i][6] = Integer.toString(GraphicalUserInterface.selectedCar.get(i).getKilometerstand());
                selectedCarsTableData[i][7] = GraphicalUserInterface.selectedCar.get(i).getErstzulassung();
                selectedCarsTableData[i][8] = GraphicalUserInterface.selectedCar.get(i).getKraftstofftyp();
                selectedCarsTableData[i][9] = Float.toString(GraphicalUserInterface.selectedCar.get(i).getFaktor());
                selectedCarsTableData[i][10] = "100";
                // CUSTOMER DOES NOT HAVE A DISCOUNT FACTOR?! - GraphicalUserInterface.selectedCustomer.getRebatt()=0?!
                float price = (float) calcPrice(GraphicalUserInterface.selectedCar.get(i).getFaktor(), GraphicalUserInterface.selectedCustomer.getRebatt(),(int) days);
                totalPrice = price + totalPrice;
                selectedCarsTableData[i][11] = dc.format(price);
            }
            rentalPriceInfo.setText(dc.format(totalPrice)+" EUR");
            if(days>1){
                totalTag.setText((int)days+" Tage");
            } else totalTag.setText((int)days+" Tag");
            

            DefaultTableModel tableModel = new DefaultTableModel(selectedCarsTableData, selectedCarsTableColums);

            rentalAutoTable.setModel(tableModel);

    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ConfirmRentalCarDialog = new javax.swing.JDialog();
        VerleihDatumLabel = new javax.swing.JLabel();
        RuckgabedatumLabel = new javax.swing.JLabel();
        FreikilometerLabel = new javax.swing.JLabel();
        BezahlstatusLabel = new javax.swing.JLabel();
        ZahlartLabel = new javax.swing.JLabel();
        ConfirmRentalButton = new javax.swing.JButton();
        AbbrechenConfirmRental = new javax.swing.JButton();
        VerleihDatumField = new javax.swing.JFormattedTextField();
        RuckgabedatumField = new javax.swing.JFormattedTextField();
        FreikilometerField = new javax.swing.JFormattedTextField();
        BezahlstatusField = new javax.swing.JComboBox();
        ZahlartField = new javax.swing.JComboBox();
        rentalTab = new javax.swing.JPanel();
        rentalAutoPanel = new javax.swing.JPanel();
        rentalAutoTableScroll = new javax.swing.JScrollPane();
        rentalAutoTable = new javax.swing.JTable();
        rentalCustomerPanel = new javax.swing.JPanel();
        rentalCustomerSurnameLabel = new javax.swing.JLabel();
        rentalCustomerSurnameInfo = new javax.swing.JLabel();
        rentalCustomerAnredeLabel = new javax.swing.JLabel();
        rentalCustomerAnredeInfo = new javax.swing.JLabel();
        rentalCustomerFirstNameLabel = new javax.swing.JLabel();
        rentalCustomerFirstNameInfo = new javax.swing.JLabel();
        rentalCustomerBirthdayLabel = new javax.swing.JLabel();
        rentalCustomerBirthdayInfo = new javax.swing.JLabel();
        rentalCustomerRegisterDateLabel = new javax.swing.JLabel();
        rentalCustomerRegisterDateInfo = new javax.swing.JLabel();
        rentalCustomerLicenseDateLabel = new javax.swing.JLabel();
        rentalCustomerLicenseDateInfo = new javax.swing.JLabel();
        rentalCustomerLicenseClassLabel = new javax.swing.JLabel();
        rentalCustomerLicenseClassInfo = new javax.swing.JLabel();
        rentalCustomerIdLabel = new javax.swing.JLabel();
        rentalCustomerIdInfo = new javax.swing.JLabel();
        rentalCustomerAddressLabel = new javax.swing.JLabel();
        rentalCustomerAddressInfo = new javax.swing.JLabel();
        rentalCustomerPhoneLabel = new javax.swing.JLabel();
        rentalCustomerPhoneInfo = new javax.swing.JLabel();
        rentalCustomerCompanyLabel = new javax.swing.JLabel();
        rentalCustomerCompanyInfo = new javax.swing.JLabel();
        rentalCustomerDiscountLabel = new javax.swing.JLabel();
        rentalCustomerDiscountInfo = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        rentalCustomerLicenseDateLabel1 = new javax.swing.JLabel();
        rentalCustomerLicenseDateLabel2 = new javax.swing.JLabel();
        zahlartField = new javax.swing.JLabel();
        verleihdatum = new javax.swing.JFormattedTextField();
        ruckgabedatum = new javax.swing.JFormattedTextField();
        bezahlstatusBox = new javax.swing.JComboBox();
        rentalCustomerLicenseDateLabel4 = new javax.swing.JLabel();
        zahlartBox = new javax.swing.JComboBox();
        totalTag = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        rentalOk = new javax.swing.JButton();
        rentalPriceInfo = new javax.swing.JLabel();

        ConfirmRentalCarDialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                ConfirmRentalCarDialogWindowClosing(evt);
            }
        });

        VerleihDatumLabel.setText("Verleihdatum");

        RuckgabedatumLabel.setText("Rückgabedatum");

        FreikilometerLabel.setText("Freikilometer");

        BezahlstatusLabel.setText("Bezahlstatus");

        ZahlartLabel.setText("Zahlart");

        ConfirmRentalButton.setText("Speichern");
        ConfirmRentalButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConfirmRentalButtonActionPerformed(evt);
            }
        });

        AbbrechenConfirmRental.setText("Abbrechen");
        AbbrechenConfirmRental.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AbbrechenConfirmRentalActionPerformed(evt);
            }
        });

        try {
            VerleihDatumField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-##-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        try {
            RuckgabedatumField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-##-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        RuckgabedatumField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RuckgabedatumFieldActionPerformed(evt);
            }
        });

        FreikilometerField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));

        BezahlstatusField.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4" }));
        BezahlstatusField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BezahlstatusFieldActionPerformed(evt);
            }
        });

        ZahlartField.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        javax.swing.GroupLayout ConfirmRentalCarDialogLayout = new javax.swing.GroupLayout(ConfirmRentalCarDialog.getContentPane());
        ConfirmRentalCarDialog.getContentPane().setLayout(ConfirmRentalCarDialogLayout);
        ConfirmRentalCarDialogLayout.setHorizontalGroup(
            ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ConfirmRentalCarDialogLayout.createSequentialGroup()
                .addContainerGap(78, Short.MAX_VALUE)
                .addComponent(AbbrechenConfirmRental)
                .addGap(43, 43, 43)
                .addComponent(ConfirmRentalButton)
                .addGap(106, 106, 106))
            .addGroup(ConfirmRentalCarDialogLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(VerleihDatumLabel)
                    .addComponent(RuckgabedatumLabel)
                    .addComponent(FreikilometerLabel)
                    .addComponent(BezahlstatusLabel)
                    .addComponent(ZahlartLabel))
                .addGap(27, 27, 27)
                .addGroup(ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(FreikilometerField)
                    .addComponent(RuckgabedatumField)
                    .addComponent(VerleihDatumField)
                    .addComponent(BezahlstatusField, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(ZahlartField, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(116, Short.MAX_VALUE))
        );
        ConfirmRentalCarDialogLayout.setVerticalGroup(
            ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ConfirmRentalCarDialogLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(VerleihDatumLabel)
                    .addComponent(VerleihDatumField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(RuckgabedatumLabel)
                    .addComponent(RuckgabedatumField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(FreikilometerLabel)
                    .addGroup(ConfirmRentalCarDialogLayout.createSequentialGroup()
                        .addComponent(FreikilometerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(BezahlstatusField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BezahlstatusLabel))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ZahlartLabel)
                    .addComponent(ZahlartField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(47, 47, 47)
                .addGroup(ConfirmRentalCarDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(AbbrechenConfirmRental)
                    .addComponent(ConfirmRentalButton))
                .addContainerGap(70, Short.MAX_VALUE))
        );

        rentalAutoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Fahrzeuge"));
        rentalAutoPanel.setMaximumSize(null);

        rentalAutoTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "ID", "Klasse", "Hersteller", "Modell", "Kennzeichen", "Sitzplätze", "Kilometerstand", "Erstzulassung", "Kraftstofftyp", "Preisfaktor", "Verleihdatum", "Freikilometer", "Preis"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        rentalAutoTable.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                rentalAutoTableKeyPressed(evt);
            }
        });
        rentalAutoTableScroll.setViewportView(rentalAutoTable);

        javax.swing.GroupLayout rentalAutoPanelLayout = new javax.swing.GroupLayout(rentalAutoPanel);
        rentalAutoPanel.setLayout(rentalAutoPanelLayout);
        rentalAutoPanelLayout.setHorizontalGroup(
            rentalAutoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rentalAutoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rentalAutoTableScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 1407, Short.MAX_VALUE)
                .addContainerGap())
        );
        rentalAutoPanelLayout.setVerticalGroup(
            rentalAutoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rentalAutoPanelLayout.createSequentialGroup()
                .addComponent(rentalAutoTableScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
                .addContainerGap())
        );

        rentalCustomerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Kunde"));

        rentalCustomerSurnameLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerSurnameLabel.setText("Nachname:");

        rentalCustomerAnredeLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerAnredeLabel.setText("Anrede:");

        rentalCustomerFirstNameLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerFirstNameLabel.setText("Vorname:");

        rentalCustomerBirthdayLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerBirthdayLabel.setText("Geburtsdatum:");

        rentalCustomerRegisterDateLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerRegisterDateLabel.setText("Anmeldungdatum:");

        rentalCustomerLicenseDateLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerLicenseDateLabel.setText("Führerscheindatum:");

        rentalCustomerLicenseClassLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerLicenseClassLabel.setText("Führerscheinklassen:");

        rentalCustomerIdLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerIdLabel.setText("Kundennummer:");

        rentalCustomerIdInfo.setText("123");

        rentalCustomerAddressLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerAddressLabel.setText("Adresse:");

        rentalCustomerPhoneLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerPhoneLabel.setText("Telefonnummer:");

        rentalCustomerCompanyLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerCompanyLabel.setText("Firmenname:");

        rentalCustomerDiscountLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerDiscountLabel.setText("Rabattfaktor:");

        javax.swing.GroupLayout rentalCustomerPanelLayout = new javax.swing.GroupLayout(rentalCustomerPanel);
        rentalCustomerPanel.setLayout(rentalCustomerPanelLayout);
        rentalCustomerPanelLayout.setHorizontalGroup(
            rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                        .addComponent(rentalCustomerAnredeLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(rentalCustomerAnredeInfo))
                                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                        .addComponent(rentalCustomerBirthdayLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(rentalCustomerBirthdayInfo))
                                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                        .addComponent(rentalCustomerLicenseDateLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(rentalCustomerLicenseDateInfo)))
                                .addGap(159, 159, 159)
                                .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                        .addComponent(rentalCustomerRegisterDateLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(rentalCustomerRegisterDateInfo))
                                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                        .addComponent(rentalCustomerLicenseClassLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 175, Short.MAX_VALUE)
                                        .addComponent(rentalCustomerLicenseClassInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(rentalCustomerSurnameLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(rentalCustomerSurnameInfo))))
                            .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                .addComponent(rentalCustomerAddressLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rentalCustomerAddressInfo)))
                        .addGap(175, 175, 175)
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                .addComponent(rentalCustomerFirstNameLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rentalCustomerFirstNameInfo)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 477, Short.MAX_VALUE)
                                .addComponent(rentalCustomerIdLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rentalCustomerIdInfo))
                            .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                .addComponent(rentalCustomerPhoneLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rentalCustomerPhoneInfo))
                            .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                                .addComponent(rentalCustomerDiscountLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rentalCustomerDiscountInfo))))
                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                        .addComponent(rentalCustomerCompanyLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rentalCustomerCompanyInfo)))
                .addContainerGap())
        );
        rentalCustomerPanelLayout.setVerticalGroup(
            rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rentalCustomerCompanyLabel)
                            .addComponent(rentalCustomerCompanyInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rentalCustomerAnredeLabel)
                            .addComponent(rentalCustomerAnredeInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rentalCustomerFirstNameInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rentalCustomerFirstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rentalCustomerIdLabel)
                            .addComponent(rentalCustomerIdInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rentalCustomerBirthdayInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rentalCustomerBirthdayLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rentalCustomerLicenseDateInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rentalCustomerLicenseDateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(rentalCustomerPanelLayout.createSequentialGroup()
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rentalCustomerSurnameInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rentalCustomerSurnameLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rentalCustomerRegisterDateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rentalCustomerRegisterDateInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rentalCustomerLicenseClassLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rentalCustomerLicenseClassInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rentalCustomerAddressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rentalCustomerAddressInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, rentalCustomerPanelLayout.createSequentialGroup()
                .addContainerGap(60, Short.MAX_VALUE)
                .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rentalCustomerDiscountInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rentalCustomerDiscountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(rentalCustomerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rentalCustomerPhoneLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rentalCustomerPhoneInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Verleih"));

        rentalCustomerLicenseDateLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerLicenseDateLabel1.setText("Verleihdatum:");

        rentalCustomerLicenseDateLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerLicenseDateLabel2.setText("Rückgabedatum:");

        zahlartField.setFont(new java.awt.Font("Tahoma", 1, 11));
        zahlartField.setText("Zahlart:");

        try {
            verleihdatum.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.##.####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        verleihdatum.setText(formatter.format(pickupDate));
        verleihdatum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                verleihdatumActionPerformed(evt);
            }
        });
        verleihdatum.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                verleihdatumFocusLost(evt);
            }
        });

        try {
            ruckgabedatum.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.##.####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        ruckgabedatum.setText(formatter.format(returnDate));
        ruckgabedatum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ruckgabedatumActionPerformed(evt);
            }
        });
        ruckgabedatum.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                ruckgabedatumFocusLost(evt);
            }
        });

        bezahlstatusBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2" }));

        rentalCustomerLicenseDateLabel4.setFont(new java.awt.Font("Tahoma", 1, 11));
        rentalCustomerLicenseDateLabel4.setText("Bezahlstatus:");

        zahlartBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Geld", "Kreditkarte" }));

        totalTag.setFont(new java.awt.Font("Tahoma", 2, 8));
        totalTag.setText("jLabel1");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rentalCustomerLicenseDateLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(verleihdatum, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addComponent(rentalCustomerLicenseDateLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ruckgabedatum, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(totalTag)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 283, Short.MAX_VALUE)
                .addComponent(zahlartField)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(zahlartBox, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(rentalCustomerLicenseDateLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bezahlstatusBox, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(bezahlstatusBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(rentalCustomerLicenseDateLabel4)
                        .addComponent(zahlartBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(zahlartField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(rentalCustomerLicenseDateLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(rentalCustomerLicenseDateLabel2)
                        .addComponent(verleihdatum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(totalTag)
                        .addComponent(ruckgabedatum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(27, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {rentalCustomerLicenseDateLabel1, rentalCustomerLicenseDateLabel2});

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Totalpreis"));

        rentalOk.setText("Ok");
        rentalOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rentalOkActionPerformed(evt);
            }
        });

        rentalPriceInfo.setFont(new java.awt.Font("Tahoma", 0, 24));
        rentalPriceInfo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        rentalPriceInfo.setText(Float.toString((float) totalPrice));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addComponent(rentalPriceInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rentalOk)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(rentalOk, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
                    .addComponent(rentalPriceInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout rentalTabLayout = new javax.swing.GroupLayout(rentalTab);
        rentalTab.setLayout(rentalTabLayout);
        rentalTabLayout.setHorizontalGroup(
            rentalTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, rentalTabLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(rentalTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, rentalTabLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(rentalAutoPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(rentalCustomerPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        rentalTabLayout.setVerticalGroup(
            rentalTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rentalTabLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rentalCustomerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rentalAutoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(rentalTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        rentalTabLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jPanel1, jPanel2});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1459, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(rentalTab, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 598, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(1, 1, 1)
                    .addComponent(rentalTab, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE)
                    .addGap(1, 1, 1)))
        );
    }// </editor-fold>//GEN-END:initComponents

private void rentalOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rentalOkActionPerformed

    ArrayList<Integer> success = new ArrayList<Integer>();
    ArrayList<Integer> failure = new ArrayList<Integer>();
    String msg = new String();
    
    for(int i=0; i<GraphicalUserInterface.selectedCar.size(); i++){
        String zuruck=   Rental.RentalaCar(GUI.LoginWindow.sessionID, rentalCustomerIdInfo.getText(),(String) rentalAutoTable.getValueAt(i, 0), formatterDatabase.format(pickupDate)               , formatterDatabase.format(returnDate)               ,(String) rentalAutoTable.getValueAt(i, 10) , (String) rentalAutoTable.getValueAt(i, 11)                   , bezahlstatusBox.getSelectedItem().toString() , zahlartBox.getSelectedItem().toString());
        if(zuruck.equals("1")){     JOptionPane.showMessageDialog(null, "Sie wurden ausgeloggt!Bitte versuchen Sie sich wieder einzuloggen","ERROR",JOptionPane.ERROR_MESSAGE) ; break;}
        if(zuruck.equals("5")){     failure.add(Integer.parseInt((String) rentalAutoTable.getValueAt(i, 0)));}
            else{
                success.add(Integer.parseInt((String) rentalAutoTable.getValueAt(i, 0)));
         }   
    }
    
    if(failure.size()>0){
        msg = "Die Verleihverwaltung existiert bereits für die folgenden Autos:";
        while(!failure.isEmpty()){
            msg = msg+" "+ failure.get(0);
            failure.remove(0);
            if(!failure.isEmpty()) msg = msg+",";
        }
        JOptionPane.showMessageDialog(null, msg,"ERROR",JOptionPane.ERROR_MESSAGE) ;
    }
    if(success.size()>0){
        msg = "Die Verleihverwaltung wurde hinzugefügt für die folgenden Autos:";
        while(!success.isEmpty()){
            System.out.println("Sucesso! "+success.get(0));
            msg = msg+" "+success.get(0);
            success.remove(0);
            if(!success.isEmpty()) msg = msg+",";
        }
        JOptionPane.showMessageDialog(null, msg,"Neue Verleihverwaltung",JOptionPane.INFORMATION_MESSAGE);
    }
    this.setEnabled(true);           
        
}//GEN-LAST:event_rentalOkActionPerformed

private void AbbrechenConfirmRentalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AbbrechenConfirmRentalActionPerformed
    ConfirmRentalCarDialog.setVisible(false);
    this.setEnabled(true);
}//GEN-LAST:event_AbbrechenConfirmRentalActionPerformed

private void ConfirmRentalCarDialogWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_ConfirmRentalCarDialogWindowClosing
    ConfirmRentalCarDialog.setVisible(false);
    this.setEnabled(true);
}//GEN-LAST:event_ConfirmRentalCarDialogWindowClosing

private void ConfirmRentalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfirmRentalButtonActionPerformed
    if(VerleihDatumField.getText().equals("    -  -  ")){VerleihDatumField.setText("0000-00-00");}
    if(RuckgabedatumField.getText().equals("    -  -  ")){RuckgabedatumField.setText("0000-00-00");}
    if(FreikilometerField.getText().equals("")){FreikilometerField.setText("0");}

 String zuruck=  Rental.RentalaCar(GUI.LoginWindow.sessionID, rentalCustomerIdInfo.getText(), "1", VerleihDatumField.getText(), RuckgabedatumField.getText(), FreikilometerField.getText(), rentalPriceInfo.getText(), BezahlstatusField.getSelectedItem().toString(), ZahlartField.getSelectedItem().toString());// TODO add your handling code here:
 if(zuruck.equals("1")){     JOptionPane.showMessageDialog(null, "Sie wurden ausgeloggt!Bitte versuchen Sie sich wieder einzuloggen","ERROR",JOptionPane.ERROR_MESSAGE) ;}
 if(zuruck.equals("5")){     JOptionPane.showMessageDialog(null, "Die Verleihverwaltung existiert bereits","ERROR",JOptionPane.ERROR_MESSAGE) ;}
 else{
                JOptionPane.showMessageDialog(null, "Die Verleihverwaltung  wurde hinzugefügt","Neue Verleihverwaltung",JOptionPane.INFORMATION_MESSAGE) ;
                this.setEnabled(true);
                ConfirmRentalCarDialog.setVisible( false);
 }

}//GEN-LAST:event_ConfirmRentalButtonActionPerformed

private void BezahlstatusFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BezahlstatusFieldActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_BezahlstatusFieldActionPerformed



private void rentalAutoTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_rentalAutoTableKeyPressed
// TODO add your handling code here:

}//GEN-LAST:event_rentalAutoTableKeyPressed

private void RuckgabedatumFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RuckgabedatumFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_RuckgabedatumFieldActionPerformed

private void verleihdatumFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_verleihdatumFocusLost
// TODO add your handling code here:
    try{    
            pickupDate = new SimpleDateFormat(masklayout).parse((String) verleihdatum.getText());
            System.out.println(pickupDate.toString());
            updateCar();
    } catch (ParseException ex) {
            Logger.getLogger(rentalTab.class.getName()).log(Level.SEVERE, null, ex);
        }
//    System.out.println("Data de retirada modificada! Data="+verleihdatum.getText());
 
}//GEN-LAST:event_verleihdatumFocusLost

private void ruckgabedatumFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ruckgabedatumFocusLost
// TODO add your handling code here:
//    
                        try {
// TODO add your handling code here:
            returnDate = new SimpleDateFormat(masklayout).parse((String) ruckgabedatum.getText());
            System.out.println(returnDate.toString());
        } catch (ParseException ex) {
            Logger.getLogger(rentalTab.class.getName()).log(Level.SEVERE, null, ex);
        }
        updateCar(); 
//    System.out.println("Data de devolucao modificada! Data="+ruckgabedatum.getText());
}//GEN-LAST:event_ruckgabedatumFocusLost

private void ruckgabedatumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ruckgabedatumActionPerformed
// TODO add your handling code here:
    try {
            returnDate = new SimpleDateFormat(masklayout).parse((String) ruckgabedatum.getText());
            System.out.println(returnDate.toString());
        } catch (ParseException ex) {
            Logger.getLogger(rentalTab.class.getName()).log(Level.SEVERE, null, ex);
        }
        updateCar(); 
//    System.out.println("Data de devolucao modificada! Data="+ruckgabedatum.getText());
}//GEN-LAST:event_ruckgabedatumActionPerformed

private void verleihdatumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verleihdatumActionPerformed
// TODO add your handling code here:
    try{    
            pickupDate = new SimpleDateFormat(masklayout).parse((String) verleihdatum.getText());
            System.out.println(pickupDate.toString());
            updateCar();
    } catch (ParseException ex) {
            Logger.getLogger(rentalTab.class.getName()).log(Level.SEVERE, null, ex);
        }
//    System.out.println("Data de retirada modificada! Data="+verleihdatum.getText());
}//GEN-LAST:event_verleihdatumActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AbbrechenConfirmRental;
    private javax.swing.JComboBox BezahlstatusField;
    private javax.swing.JLabel BezahlstatusLabel;
    private javax.swing.JButton ConfirmRentalButton;
    private javax.swing.JDialog ConfirmRentalCarDialog;
    private javax.swing.JFormattedTextField FreikilometerField;
    private javax.swing.JLabel FreikilometerLabel;
    private javax.swing.JFormattedTextField RuckgabedatumField;
    private javax.swing.JLabel RuckgabedatumLabel;
    private javax.swing.JFormattedTextField VerleihDatumField;
    private javax.swing.JLabel VerleihDatumLabel;
    private javax.swing.JComboBox ZahlartField;
    private javax.swing.JLabel ZahlartLabel;
    private javax.swing.JComboBox bezahlstatusBox;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel rentalAutoPanel;
    private static javax.swing.JTable rentalAutoTable;
    private javax.swing.JScrollPane rentalAutoTableScroll;
    private static javax.swing.JLabel rentalCustomerAddressInfo;
    private javax.swing.JLabel rentalCustomerAddressLabel;
    private static javax.swing.JLabel rentalCustomerAnredeInfo;
    private javax.swing.JLabel rentalCustomerAnredeLabel;
    private static javax.swing.JLabel rentalCustomerBirthdayInfo;
    private javax.swing.JLabel rentalCustomerBirthdayLabel;
    private static javax.swing.JLabel rentalCustomerCompanyInfo;
    private javax.swing.JLabel rentalCustomerCompanyLabel;
    private static javax.swing.JLabel rentalCustomerDiscountInfo;
    private javax.swing.JLabel rentalCustomerDiscountLabel;
    private static javax.swing.JLabel rentalCustomerFirstNameInfo;
    private javax.swing.JLabel rentalCustomerFirstNameLabel;
    private static javax.swing.JLabel rentalCustomerIdInfo;
    private javax.swing.JLabel rentalCustomerIdLabel;
    private static javax.swing.JLabel rentalCustomerLicenseClassInfo;
    private javax.swing.JLabel rentalCustomerLicenseClassLabel;
    private static javax.swing.JLabel rentalCustomerLicenseDateInfo;
    private javax.swing.JLabel rentalCustomerLicenseDateLabel;
    private javax.swing.JLabel rentalCustomerLicenseDateLabel1;
    private javax.swing.JLabel rentalCustomerLicenseDateLabel2;
    private javax.swing.JLabel rentalCustomerLicenseDateLabel4;
    private javax.swing.JPanel rentalCustomerPanel;
    private static javax.swing.JLabel rentalCustomerPhoneInfo;
    private javax.swing.JLabel rentalCustomerPhoneLabel;
    private static javax.swing.JLabel rentalCustomerRegisterDateInfo;
    private javax.swing.JLabel rentalCustomerRegisterDateLabel;
    private static javax.swing.JLabel rentalCustomerSurnameInfo;
    private javax.swing.JLabel rentalCustomerSurnameLabel;
    private javax.swing.JButton rentalOk;
    private static javax.swing.JLabel rentalPriceInfo;
    private javax.swing.JPanel rentalTab;
    private javax.swing.JFormattedTextField ruckgabedatum;
    private static javax.swing.JLabel totalTag;
    private javax.swing.JFormattedTextField verleihdatum;
    private javax.swing.JComboBox zahlartBox;
    private javax.swing.JLabel zahlartField;
    // End of variables declaration//GEN-END:variables
    
     
    String masklayout = "dd.MM.yyyy";
    static double totalPrice;   
    static Date pickupDate = new Date();
    
    static Date returnDate = new Date(pickupDate.getTime()+((1000*24*60*60)));
    SimpleDateFormat formatter = new SimpleDateFormat(masklayout);
    SimpleDateFormat formatterDatabase = new SimpleDateFormat("yyyy-MM-dd");
    
    
    static DecimalFormat dc = new DecimalFormat("#.##");  
     
    
}
